package com.leen.video.controller;

import com.leen.common.vo.ResultEnum;
import com.leen.common.vo.ResultVO;
import com.leen.video.entity.LocalStorage;
import com.leen.video.entity.Log;
import com.leen.video.repository.LogRepository;
import com.leen.video.service.LogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@Api(tags = "系统日志接口API")
@RequestMapping(value = "/video")
public class LogController {

    @Autowired
    private LogService logService;

    @ApiOperation(value = "全查询")
    @GetMapping(value = "/log/findAll")
    public ResultVO<ResultVO> findAll(){
        return ResultVO.success(this.logService.findAll());
    }

    @ApiOperation(value = "新增数据")
    @PostMapping(value = "/log/add")
    public ResultVO<String> add(@RequestBody Log log){
        Log save =this.logService.save(log);
        return save!=null? ResultVO.success(ResultEnum.DB_SUCCESS):ResultVO.failed(ResultEnum.DB_FAILED);
    }

    @ApiOperation(value = "修改数据")
    @PostMapping(value = "/log/updata")
    public ResultVO<String> updata(@RequestBody Log log){
        Log updata = this.logService.save(log);
        return updata!=null? ResultVO.success(ResultEnum.DB_SUCCESS):ResultVO.failed(ResultEnum.DB_FAILED);
    }

}


